Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add contract to migrate a Safe from not L2 to L2 #685

Merged
merged 13 commits into from
Oct 31, 2023
Merged

Add contract to migrate a Safe from not L2 to L2 #685

merged 13 commits into from
Oct 31, 2023

Conversation

Uxio0
Copy link
Member

@Uxio0 Uxio0 commented Oct 19, 2023

Add contract to migrate a Safe from not L2 to L2

@github-actions
Copy link

Pull Request Test Coverage Report for Build 6578252603

  • 15 of 18 (83.33%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.7%) to 94.487%

Changes Missing Coverage Covered Lines Changed/Added Lines %
contracts/libraries/SafeToL2Migration.sol 15 18 83.33%
Totals Coverage Status
Change from base Build 6494000556: -0.7%
Covered Lines: 383
Relevant Lines: 395

💛 - Coveralls

@Uxio0 Uxio0 changed the title migrate l2 Add contract to migrate a Safe from not L2 to L2 Oct 19, 2023
@coveralls
Copy link

coveralls commented Oct 20, 2023

Pull Request Test Coverage Report for Build 6626835905

Details

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.3%) to 94.907%

Totals Coverage Status
Change from base Build 6589591326: -0.3%
Covered Lines: 381
Relevant Lines: 390

💛 - Coveralls

@Uxio0 Uxio0 marked this pull request as ready for review October 20, 2023 12:18
@mmv08 mmv08 requested review from a team, rmeissner, nlordell, akshay-ap and mmv08 and removed request for a team October 20, 2023 12:36
@@ -0,0 +1,129 @@
// SPDX-License-Identifier: LGPL-3.0-only
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

comment: Completely unrelated to this PR, but maybe it would make sense to group all migration contracts in a contracts/migrations root directory? Not suggesting doing this as part of this PR, but if I were to jump into the codebase without any context, I would find looking for migration contracts in a separate root slightly more natural and intuitive. Food for thought...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes total sense, I found it weird but I put it on the same directory as the rest of the migrations

@Uxio0
Copy link
Member Author

Uxio0 commented Oct 24, 2023

@rmeissner Do you think support for migrating v1.1.1 to L2 is required? (I would need to emit SafeCreation event for those Safes)

contracts/libraries/SafeToL2Migration.sol Outdated Show resolved Hide resolved
contracts/libraries/SafeToL2Migration.sol Show resolved Hide resolved
test/libraries/SafeToL2Migration.spec.ts Outdated Show resolved Hide resolved
@Uxio0
Copy link
Member Author

Uxio0 commented Oct 25, 2023

@nlordell @mmv08 I added a method and a test for migrating from V1.1.1. In that case 2 more steps need to be performed, setting up the according fallback handler and emitting the SafeSetup event so the backend can index the Safe. There are a lot of 1.1.1 Safes and I think it's worth it to support them.

);

ISafe safe = ISafe(address(this));
safe.setFallbackHandler(fallbackHandler);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this only happen if the default fallback handler is used? Otherwise it could be unintentionally overwriting a custom fallback handler.

Copy link
Member Author

@Uxio0 Uxio0 Oct 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, but:

  • For the reasons exposed before, it's difficult to know which is the default fallback handler, and more for the 1.1.1 where we didn't do a big follow up on safe-deployments.
  • I don't think it will be intended for a user to update to 1.3.1/1.4.1 but still keep their old custom fallback handler.
  • This smart contract is done thinking on get the Safe supported on our UI. If they need to use the UI the official fallback handler is required, otherwise for example offchain messages might not work.
  • If the user developed a custom fallback handler they should be able to use this contract to set it up back or even a new custom one.

}

/**
* @notice Migrate from Safe 1.1.1 Singleton to 1.3.1 or 1.4.1 L2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
* @notice Migrate from Safe 1.1.1 Singleton to 1.3.1 or 1.4.1 L2
* @notice Migrate from Safe 1.1.1 Singleton to 1.3.0 or 1.4.1 L2

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ops

Uxio0 added 4 commits October 26, 2023 16:31
- Hardcode nonce 0 in event instead of nonce - 1, should be more gas efficient
@Uxio0 Uxio0 merged commit 482332f into main Oct 31, 2023
18 checks passed
@Uxio0 Uxio0 deleted the migrate-l2 branch October 31, 2023 10:49
@Uxio0
Copy link
Member Author

Uxio0 commented Oct 31, 2023

For context, we tested it on Polygon:

2 non L2 Safes were created and were converted to L2 Safes:

  • 0x18D339380c46F431ddbD32b6f4749f6Aca24Be80 : v1.1.1
  • 0x8C852E7Cb94512E6325C7460Fd2A352920717c70 : v1.3.0 (not L2)

Thanks @JagoFigueroa !

Saw-mon-and-Natalie pushed a commit to Saw-mon-and-Natalie/safe-contracts that referenced this pull request Nov 1, 2023
mmv08 pushed a commit that referenced this pull request Jul 22, 2024
* Add contract to migrate a Safe from not L2 to L2
* Related to safe-global/safe-transaction-service#1703
mmv08 added a commit that referenced this pull request Jul 23, 2024
This PR implements
#781.

It migrates the migration contracts from:
- #685
- #793

I had to refactor tests quite a bit because a lot has changed since the
release of 1.4.1 like we added typechain types, migrated to ethers v6,
etc

---------

Co-authored-by: Akshay <[email protected]>
Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>
Co-authored-by: Shebin John <[email protected]>
Co-authored-by: Uxío <[email protected]>
dodger213 added a commit to dodger213/safe-smart-contract that referenced this pull request Aug 18, 2024
This PR implements
safe-global/safe-smart-account#781.

It migrates the migration contracts from:
- safe-global/safe-smart-account#685
- safe-global/safe-smart-account#793

I had to refactor tests quite a bit because a lot has changed since the
release of 1.4.1 like we added typechain types, migrated to ethers v6,
etc

---------

Co-authored-by: Akshay <[email protected]>
Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>
Co-authored-by: Shebin John <[email protected]>
Co-authored-by: Uxío <[email protected]>
nlordell added a commit that referenced this pull request Sep 10, 2024
This PR implements
#781.

It migrates the migration contracts from:
- #685
- #793

I had to refactor tests quite a bit because a lot has changed since the
release of 1.4.1 like we added typechain types, migrated to ethers v6,
etc

---------

Co-authored-by: Akshay <[email protected]>
Co-authored-by: Nicholas Rodrigues Lordello <[email protected]>
Co-authored-by: Shebin John <[email protected]>
Co-authored-by: Uxío <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants